<?php
/**
 * ClientScript class file.
*/
class ClientScript extends CClientScript
{
	public $defaultJuiTheme = 'base';
	public $juiScriptFile = 'jquery-ui.min.js';
	public $juiCssFile = 'jquery.ui.all.css';
	public $juiI18nScriptFile = 'jquery-ui-i18n.js';

	public function registerJuiScripts($cssFile = '', $theme = '', $useI18n = false, $position=ClientScript::POS_END)
	{
		if($cssFile === '')
			$cssFile = $this->juiCssFile;
		if($theme === '')
			$theme = $this->defaultJuiTheme;

		$basePath=Yii::getPathOfAlias('zii.vendors.jui');
		$baseUrl=Yii::app()->getAssetManager()->publish($basePath, true);

		$scriptUrl=$baseUrl.'/js';
		$cssUrl=$baseUrl.'/css';

		$this->registerCssFile($cssUrl.'/'.$theme.'/'.$cssFile);
		$this->registerCoreScript('jquery');
		$this->registerScriptFile($scriptUrl.'/'.$this->juiScriptFile, $position);
		if($useI18n)
			$this->registerScriptFile($scriptUrl.'/'.$this->juiI18nScriptFile, $position);
	}
}